<!DOCTYPE html>
<html>
<head>
    <title>我的结伴</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/checkLogin.js"></script>
    <script>
        var currentPage = 1;//当前页
        var totalPage;//总页数
        var travelArr = [];//存放页面的容器
        var loading = false;//判定请求数据是否传完的标记


        function query() {
            if (loading) {//如果是加载状态就不发送请求
                return;
            }
            loading = true;//进入加载状态
            $.get(baseUrl + "togethers/"+user.id, {currentPage: currentPage}, function (data) {
                //每次查询都要把页面信息合并到容器中
                $.merge(travelArr, data.list);
                var json = {list: travelArr};
                $(".travels").renderValues(json,{
                    'getHref':getHref
                });
                //没查询一次当前页数加1
                currentPage++;
                //获取数据的总页数
                totalPage = data.pages;
                loading = false;//加载完成后把状态改成可以发送请求的状态
            });

        }

        $(function () {
            //默认自动查询第一页数据
            query();
            $(window).scroll(function () {
                //如果页面的滚动长度加窗口长度等于页面的总长度时 发送请求查询下一页数据
                if ($(document).scrollTop() + $(window).height() >= $(document).height() - 50) {//提前五十像素发送请求
                    //当前页小于总页数的时候才查询
                    if (currentPage <= totalPage) {
                        query();
                    } else {
                        $(document).dialog({
                            type: 'notice',
                            infoIcon: '../img/icon/loading.gif',
                            infoText: '不要拉了,再拉就出屎了!',
                            autoClose: 2500
                        });
                    }

                }
            })
        })


    </script>


</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="profiles.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的结伴</span>
        </div>
        <div class="col"></div>
    </div>
</div>


<div class="container travels">
    <dl class="list" render-loop="list">
        <dd>
            <a data-url="/mine/editTogether.html?id=" render-fun="getHref" render-key="list.id" >
                <img render-src="list.coverUrl">
                <h6 class="title" render-html="list.title"></h6>
                <p>最近更新时间 <span render-html="list.lastUpdateTime"></span>
                    <span class="span-right">
							  <i class="fa fa-heart"></i><span>0</span>收藏
						  <i class="fa fa-thumbs-o-up"></i><span>0</span>点赞</span>
                </p>
            </a>
        </dd>

    </dl>
</div>

</body>
</html>
